function [answers confidence times] = bayesianMeta(results, cms, zeroSubstitute=0.000001)
	answers=[];
	confidence=[];
	times=zeros(1,10);
	for(sample=1:size(results,1))
		bel=zeros(10,1);
		for(i=1:size(bel,1))
			if(sum(results(sample,:)==(i-1))==0)
				continue;
			end;
			numerator=NaN;
			
			firstLoopStart=cputime;
			for(classifier=1:size(cms,2))
				if(isnan(numerator))
					numerator=1;
				end;
				predicted = results(sample,classifier);
				if(sum(cms{classifier}(:,predicted+1))==0)
					printf("upper %f \n", sum(cms{classifier}(:,predicted+1)));
				end;
				numerator*=(max(cms{classifier}(i,results(sample,classifier)+1),zeroSubstitute)/sum(cms{classifier}(:,predicted+1)));
				fflush(stdout);
			end;
			#printf("numerator: %f \n", numerator);
			times(1,1)+=cputime-firstLoopStart;
			
			denominator=0;
			
			#clazz - no "+1" term!
			secLoopStart=cputime;
			for(clazz=1:size(cms{1},1))
				partial=NaN;
				for(classifier=1:size(cms,2))
					if(isnan(partial))
						partial=1;
					end;
					predicted = results(sample,classifier);
					if(sum(cms{classifier}(:,predicted+1))==0)
						printf("lower %f \n", sum(cms{classifier}(:,predicted+1)));
					end;
					partial*=(max(cms{classifier}(clazz,results(sample,classifier)+1),zeroSubstitute) / sum(cms{classifier}(:,predicted+1)));
					fflush(stdout);
				end;
				denominator+=partial;
			end;
			times(1,2)+=cputime-secLoopStart;
			if(numerator==0)
				bel(i,1)=0;
			elseif(denominator==0)
				bel(i,1)=NaN;
			else
				bel(i,1)=numerator/denominator;
			end;
		end;
		[maxVal maxPos] = max(bel);

		if(maxVal==0)
			answers=[answers; 10];
		else
			answers=[answers; maxPos-1];
			confidence=[confidence; maxVal/sum(bel)];
		end;
	end;
end;
